package cn.rulian;

import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import cn.rulian.base.common.interceptor.AuthInterceptor;

/**
 * SpringBoot启用入口 <br>
 * 会自动扫描该类同级包及下级包里的Bean <br>
 */

@SpringBootApplication
public class StartApplication extends WebMvcConfigurerAdapter
{
	public static void main(String[] args)
	{
		System.out.println("Rulian Spring 开始启动...");
		
		SpringApplication.run(StartApplication.class, args);
		
		/* 关闭启动图案的启动方式
		SpringApplication app=new SpringApplication(RulianApplication.class);
		app.setBannerMode(Banner.Mode.OFF);
		app.run(args);
		*/
		
		System.out.println("---------------------------------------------------------------------");
		System.out.println("Rulian Spring 启动完成！");
		System.out.println("---------------------------------------------------------------------");
	}
	
	/**
	 * 将权限过滤器加入Spring容器管理
	 */
	@Bean
	AuthInterceptor authInterceptor() {
        return new AuthInterceptor();
    }
	
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
    	registry.addInterceptor(authInterceptor()).addPathPatterns("/**");
	}
	
	
}
